{template 'common/header'}
<div class="panel we7-panel ng-scope" >
	<div class="panel-heading">综合设置</div>
	<div class="panel-body we7-padding">
			<div class="form-horizontal">
			<div class="form-group">
				<label class="col-sm-2 control-label">企业/门店名称</label>
				<div class="col-sm-8">
					<input type="text" class="form-control" id="companyname" name="companyname" value="{$settings['companyname']}">
					
				</div>
		 	</div>	
			<div class="form-group">
				<label class="col-sm-2 control-label">企业地址</label>
				<div class="col-sm-8">
					<input type="text" class="form-control" id="address" name="address" value="{$settings['address']}">
				</div>
		 	</div>		 		 	
			<div class="form-group">
				<label class="col-sm-2 control-label">营业起始/结束时间</label>
				<div class="col-sm-4">
					<input type="text" class="form-control" id="starthours" name="starthours" value="{$settings['starthours']}">
					<span class="help-block">&nbsp;&nbsp;例如：08:00-20:30,请严格按照格式填写!</span>	
				</div>
				<div class="col-sm-4">
					<input type="text" class="form-control" id="endhours" name="endhours" value="{$settings['endhours']}">
				</div>	
							
		 	</div>	 		
			<div class="form-group">
				<label class="col-sm-2 control-label">联系电话</label>
				<div class="col-sm-8">
					<input type="text" class="form-control" id="phone" name="phone" value="{$settings['phone']}">
				</div>
		 	</div> 
			<div class="form-group">
				<label class="col-sm-2 control-label">管理员OPENID</label>
				<div class="col-sm-8">
					<input type="text" class="form-control" id="openid" name="openid" value="{$openid}">
					<span class="help-block">&nbsp;&nbsp;设置对应管理消息推送平台下管理员的OPENID，多个以 || 分隔。我们非常建议配置公众平台下的OPENID，此openid在24小时内与小程序有客服互动，48小时内与微信公众号有互动，如若不满足，无法实现管理消息通知。</span>
				</div>
		 	</div>
			<div class="form-group">
				<label class="col-sm-2 control-label">管理员手机</label>
				<div class="col-sm-8">
					<input type="text" class="form-control" id="admin_phone" name="admin_phone" value="{$admin_phone}">
					<span class="help-block">&nbsp;&nbsp; 多个请以 || 分割 ，每个手机号每天可推送50次 需要开启请配置参数设置</span>
				</div>
		 	</div>		 	 
		    <div class="form-group">
		        <label class="col-sm-2 control-label">选择推送平台</label>
		        <div class="col-sm-8">
		        <label class="radio-inline">
		          <input type="radio" name="msg_roof" id="msg_roof" value="1" {if $settings['msg_roof']=='1'}checked="checked"{else}{/if}>微信公众号</label>
		          <label class="radio-inline">	
		          <input type="radio" name="msg_roof" id="msg_roof" value="2" {if $settings['msg_roof']=='2'}checked="checked"{else}{/if}>小程序
		        </label>
		        <span class="help-block">&nbsp;&nbsp;推荐使用公众平台作为管理消息推送，小程序端有次数限制,</span>
		      </div>            
		    </div>		    	
		    <div class="form-group">
		        <label class="col-sm-2 control-label">是否开启支付预约</label>
		        <div class="col-sm-8">
		        <label class="radio-inline">
		          <input type="radio" name="is_pay" id="is_pay" value="0" {if $settings['is_pay']=='0'}checked="checked"{else}{/if}>关闭</label>
		          <label class="radio-inline">	
		          <input type="radio" name="is_pay" id="is_pay" value="1" {if $settings['is_pay']=='1'}checked="checked"{else}{/if}>开启
		        </label>
		        <span class="help-block">&nbsp;&nbsp;不需要开通支付功能请关闭</span>
		      </div>            
		    </div>			    	 			 				 		

			<div class="form-group">
				<label class="col-sm-2 control-label">logo</label>
				<div class="col-sm-8">
					  {php echo tpl_form_field_image('logo',$settings['logo']);}
				</div>
		 	</div>						 		 	
			<div class="form-group">
				<label class="col-sm-2 control-label">展示视频</label>
				<div class="col-sm-8">
					  {php echo tpl_form_field_video('video',$settings['videourl']);}
				</div>
		 	</div>
			<div class="form-group">
				<label class="col-xs-12 col-sm-3 col-md-2 col-lg-2 control-label">展示图集</label>
				<div class="col-sm-8">
					{php echo tpl_form_field_multi_image('pics',$pics);}
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label">小程序消息模板ID</label>
				<div class="col-sm-8">
					<input type="text" class="form-control" id="msg_templateid" name="msg_templateid" value="{$settings['msg_templateid']}">
					<span class="help-block">&nbsp;&nbsp;ID:AT0104 选用字段: 姓名 预约项目 预约时间 订单号 技师号码 门店 备注 </span>
				</div>
		 	</div>			
			<div class="form-group">
				<label class="col-sm-2 control-label">版权信息</label>
				<div class="col-sm-8">
					<input type="text" class="form-control" id="copyright" name="copyright" value="{$settings['copyright']}">
						<span class="help-block">&nbsp;&nbsp;例如：Copyright © 2016-2017 xxx有限公司</span>
				</div>
		 	</div>					
			<div class="form-group">
				<label class="col-xs-12 col-sm-3 col-md-2 col-lg-2 control-label">地理位置</label>
				<div class="col-sm-8">
					{php echo tpl_form_field_coordinate('data[map]', $maps);}
				</div>
				<input type="hidden" name="lat" id="lat" value="">
				<input type="hidden" name="lng" id="lng" value="">
			</div>	
			<br/>			 	
			<button type="button" id="save_info" class="btn btn-info" style="display: block; margin-left: auto;margin-right: auto;">提交保存</button>
		</div>
	</div>
</div>
<style type="text/css">.right-content{padding: 0;}</style>
<link rel="stylesheet" href="{MODULE_URL}public/css/Toast.css">
<script src="{MODULE_URL}public/js/Toast.js"></script>  
<script charset="utf-8" src="https://map.qq.com/api/js?v=2.exp&key={$settings['tenkey']}"></script>
<script type="text/javascript" charset="utf-8" src="https://map.qq.com/api/js?v=2.exp&key={$settings['tenkey']}&libraries=convertor"></script>
<script>
	$("#save_info").on(
        "click",function(){
        	var lngV = $.trim($('input[name="data[map][lng]"]').val());
        	var latV = $.trim($('input[name="data[map][lat]"]').val());
        	if (lngV==''|| latV==''){
        		mqToast({type:1,context: '请设置地理位置'});
        		return false;
        	}
			qq.maps.convertor.translate(new qq.maps.LatLng(latV,lngV), 3, function (res) {
		   　　	latlng = res[0];
		   		var lat  = latlng['lat'];
		   		var lng  = latlng['lng'];
		   		var companyname = $.trim($('#companyname').val());
		   		var starthours = $.trim($('#starthours').val());
		   		var endhours = $.trim($('#endhours').val());
		   		var msg_templateid = $.trim($('#msg_templateid').val());
		   		// var trade = $.trim($('#trade').val());
		   		var phone = $.trim($('#phone').val());
		   		var appid = $.trim($('#appid').val());
		   		var appsecret = $.trim($('#appsecret').val());
		   		// var bg_color = $.trim($('input[name="color"]').val());
		   		var logo = $.trim($('input[name="logo"]').val());
		   		var video = $.trim($('input[name="video"]').val());
		   		var audio = $.trim($('input[name="audio"]').val());
		   		var copyright = $.trim($('#copyright').val());	
		   		var address = $.trim($('#address').val());
				var Blng = $.trim($('input[name="data[map][lng]"]').val());
	        	var Blat = $.trim($('input[name="data[map][lat]"]').val());	
	        	var openid = $.trim($('#openid').val());
	        	var admin_phone = $.trim($('#admin_phone').val());
	        	var picArr = $('input[name="pics[]"]').map(function(){return $(this).val()}).get();
	        	var pics = picArr.join(',');   	
	        	var msg_roof =$.trim($("input[name='msg_roof']:checked").val());
	        	var is_pay = $.trim($("input[name='is_pay']:checked").val());  	
		   		if(companyname==''){
		   			mqToast({type:1,context: '请填写 企业/门店名称'});
		   			return false;
		   		}
		   		if(starthours=="" || endhours==""){
		   			mqToast({type:1,context: '请填写 营业起始/结束时间'});
		   			return false;
		   		}	   		
		   		if(!phone){
		   			mqToast({type:1,context:'请填写联系电话'});
		   			return false;
		   		}			   		
				$.ajax({
					url:"{php echo $this->createWebUrl('save_setinfo');}&version_id="+"{$_GPC['version_id']}",
					data:{lat:lat,lng:lng,companyname:companyname,starthours:starthours,endhours:endhours,phone:phone,video:video,pics:pics,copyright:copyright,address:address,Blat:Blat,Blng:Blng,logo:logo,msg_templateid:msg_templateid,openid:openid,msg_roof:msg_roof,is_pay:is_pay,admin_phone:admin_phone},
					dataType:"json",
					type:"post",
					success:function(res){
						if(res.status==1){
							mqToast({type:1,context:res.msg});
							return false;
						}else{
							mqToast({type:2,context:res.msg});
							return false;
						}
					}
				});		   		
			});
        });

</script>
{template 'common/footer'}
